package test.generic;

/**
 * Created by linshuo on 2017/12/21.
 * <p>
 * 弥补泛型缺陷的补救措施--接口法
 * 利用 定义接口 + <T extend class> 解决
 */

interface Human {
    void speak();
}

class Boy implements Human {
    @Override
    public void speak() {
        System.out.println("I am a boy!");
    }
}

class DoSpeech1<T extends Human> {
    public void startSpeech(T human) {
        human.speak();
    }
}

public class GenericFlawRepair {
    public static void main(String[] args) {
        DoSpeech1<Boy> speech = new DoSpeech1<Boy>();
        speech.startSpeech(new Boy());
    }
}
